const echarts = require('echarts');
var myChart = echarts.init(document.getElementById('main'));
// 绘制图表
let moduleExports = {
  opt: {
    title: {
      show: false,
    },
    tooltip: {
      trigger: 'axis',
    },
    legend: {
      top: '5%',
      data: ['浏览人数', '访客人数', '订单数量', '成交金额'],
    },
    grid: {
      show: true,
      left: '10%',
      right: '10%',
      bottom: '15%',
      containLabel: true,

    },
    // dataZoom: [
    //   {
    //     type: 'slider',
    //     show: true,
    //     xAxisIndex: [0],
    //     start: 1,
    //     end: 100,
    //   },
    // ],
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: [],
    },
    yAxis: {
      type: 'value',
    },
    series: [
      {
        itemStyle: {
          normal: {
            color: 'rgba(0,158,255,1)',
          },
        },
        name: '浏览人数',
        type: 'line',
        stack: '总量',
        smooth: true,
        data: [],
      },
      {
        itemStyle: {
          normal: {
            color: 'rgba(255,186,0,1)',
          },
        },
        name: '访客人数',
        type: 'line',
        stack: '总量',
        smooth: true,
        data: [],
      },
      {
        itemStyle: {
          normal: {
            color: 'rgba(255,124,9,1)',
          },
        },
        name: '订单数量',
        type: 'line',
        stack: '总量',
        smooth: true,
        data: [],
      },
      {
        itemStyle: {
          normal: {
            color: 'rgba(255,99,143,1)',
          },
        },
        name: '成交金额',
        type: 'line',
        stack: '总量',
        smooth: true,
        data: [],
      },
    ],
  },
  getecharts: function() {
    // body...
    moduleExports.echarts = myChart.setOption(moduleExports.opt);
  },
};
module.exports = moduleExports;
